package com.fmi.timedealer.achievement;

import java.io.Serializable;
import java.util.ArrayList;

public class AchievementLevel implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8327478970727611009L;
	private ArrayList<AchievementLevelItem> items;
	private int level;
	private String name;
	private String goalMessage;
	private int id;
	private boolean isCompleted;

	public AchievementLevel(int id, ArrayList<AchievementLevelItem> achItems, int lvl, String message, String name, boolean isCompleted) {
		this.items = achItems;
		this.level = lvl;
		this.goalMessage = message;
		this.name = name;
		this.id = id;
		this.isCompleted = isCompleted;
	}
	
	public AchievementLevel(int id, int lvl, String message, String name, boolean isCompleted) {
		 this(id, new ArrayList<AchievementLevelItem>(), lvl, message, name, isCompleted);
	}
	
	public AchievementLevel(int lvl) {
		this(0, new ArrayList<AchievementLevelItem>(), lvl, "", "", false);
	}
	
	public void updateCompleted() {
		boolean completed = true;
		for (AchievementLevelItem item : this.items) {
			if (!item.isCompleted()) {
				completed = false;
				break;
			}
		}
		this.isCompleted = completed;
	}
	
	public void addAchievementItem(AchievementLevelItem item) {
		if (this.items == null) {
			this.items = new ArrayList<AchievementLevelItem>();
		}
		this.items.add(item);
	}
	
	public void removeAchievementItem(AchievementLevelItem item) {
		if (this.items != null) {
			this.items.remove(item);
		}
	}
	
	public ArrayList<AchievementLevelItem> getItems() {
		return items;
	}
	public void setItems(ArrayList<AchievementLevelItem> items) {
		this.items = items;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public String getGoalMessage() {
		return goalMessage;
	}
	public void setGoalMessage(String goalMessage) {
		this.goalMessage = goalMessage;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public boolean isCompleted() {
		return isCompleted;
	}

	public void setCompleted(boolean isCompleted) {
		this.isCompleted = isCompleted;
	}
}
